 package srdb.migration.dbhandler.enterprisedb;
 
 import srdb.migration.dbhandler.srdb.SRDBTransformDDL;
import srdb.migration.schema.metadata.Column;
import srdb.migration.schema.metadata.Function;
import srdb.migration.schema.metadata.Package;
import srdb.migration.schema.metadata.Procedure;
import srdb.migration.schema.metadata.Synonym;
import srdb.migration.schema.metadata.Trigger;

 import com.edb.commons.db.DBUtils;
 
 public class EDBTransformDDL extends SRDBTransformDDL
 {
   protected String getColumnLine(Column column)
   {
     String str = "";
     String colName = column.getName();
 
     if ((!column.isCaseSensitive()) && (colName.indexOf('#') >= 0)) {
       colName = "\"" + colName.toLowerCase() + "\"";
     }
 
     str = str + getIndent() + colName + " " + column.getDataTypeString();
 
     if (((column.getDataType() == Column.DataType.VARCHAR) || (column.getDataType() == Column.DataType.NVARCHAR)) && (column.getLength() > 0))
     {
       str = str + "(" + column.getLength() + ")";
     }
     if (((column.getDataType() == Column.DataType.INTEGER) && (!column.isWholeNumberType())) || ((column.getDataType() == Column.DataType.NUMERIC) && (!column.isReal())))
     {
       if (column.getPrecision() > 0) {
         str = str + "(" + column.getPrecision();
         if (column.getScale() > 0)
           str = str + "," + column.getScale();
         str = str + ")";
       }
 
     }
 
     if (column.getDefaultClause() != null) {
       str = str + " DEFAULT " + column.getDefaultClause();
     }
 
     if (!column.isNullable()) {
       str = str + " NOT NULL";
     }
     return str;
   }
 
   public String getCreateScript(Trigger trigger)
   {
     return trigger.getBody();
   }
 
   public String getCreateScript(Synonym syn)
   {
     String sql = "CREATE OR REPLACE SYNONYM ";
 
     if (syn.getSchema() != null) {
       sql = sql + DBUtils.quoteIdentifier(syn.getSchema()) + ".";
     }
 
     sql = sql + DBUtils.quoteIdentifier(syn.getSynname()) + "\n";
     sql = sql + getIndent() + " FOR ";
 
     if (syn.getSynObjSchema() != null) {
       sql = sql + DBUtils.quoteIdentifier(syn.getSynObjSchema()) + ".";
     }
 
     sql = sql + DBUtils.quoteIdentifier(syn.getSynobjname()) + ";\n";
     return sql;
   }
 
   public String getCreateScript(Procedure proc)
   {
     return proc.getSQL();
   }
 
   public String getCreateScript(Function func)
   {
     return func.getSQL();
   }
 
   public String getCreateScriptPackageSpec(Package pack)
   {
     return pack.getHeaderSQL();
   }
 
   public String getCreateScriptPackageBody(Package pack)
   {
     return pack.getBodySQL();
   }
 }

/* 

 * 
 */